package com.example.demo.enums;

import lombok.Getter;

/**
 * CartInvalidEnum
 *
 * @author haochen78
 * @date 2025/11/13 08:44
 **/
@Getter
public enum CartInvalidEnum {

    OFF_SHELF("OFF_SHELF", "商品已下架"),
    OUT_OF_STOCK("OUT_OF_STOCK", "库存不足"),
    PRICE_CHANGED("PRICE_CHANGED", "价格已变动"),
    SKU_UNAVAILABLE("SKU_UNAVAILABLE", "规格不可用"),
    PRODUCT_DELETED("PRODUCT_DELETED", "商品已删除"),
    PAID("PAID", "已支付"),
    ORDER_PLACED("ORDER_PLACED", "已下单"),
    EXPIRED("EXPIRED", "购物车项过期"),
    ADMIN_INVALIDATED("ADMIN_INVALIDATED", "管理员下架");

    private final String code;
    private final String message;

    CartInvalidEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static CartInvalidEnum fromCode(String code) {
        for (CartInvalidEnum r : values()) {
            if (r.code.equals(code)) {
                return r;
            }
        }
        return null;
    }
}
